#include <sys/time.h>
#include <sys/timeb.h>
#include <time.h>
#include <stdio.h>

int main(int argc, char* argv)
{
#if 0
    struct timezone tz;
    struct timeval tv;
    gettimeofday(&tv, &tz);
    struct tm* localTm = localtime(&tv.tv_sec);
    printf("%d-%02d-%02d %02d:%02d:%02d.%03d\n",
            localTm->tm_year + 1900,
            localTm->tm_mon + 1,
            localTm->tm_mday,
            localTm->tm_hour,
            localTm->tm_min,
            localTm->tm_sec,
            tv.tv_usec/1000);
#else
    struct timeb tp;
    ftime(&tp);
    struct tm* localTm = localtime(&tp.time);
    printf("%d-%02d-%02d %02d:%02d:%02d.%03d\n",
            localTm->tm_year + 1900,
            localTm->tm_mon + 1,
            localTm->tm_mday,
            localTm->tm_hour,
            localTm->tm_min,
            localTm->tm_sec,
            tp.millitm); 
#endif
    return 0;
}
